import re


def is_expression_valid(expr):
    # 使用正则表达式检查表达式是否只包含允许的字符
    allowed_chars = r"^[a-c0-9+\-*/().<> =]*$"
    if not re.match(allowed_chars, expr):
        raise ValueError("Invalid characters in the expression")
    return True


def evaluate_expression(expression, a_value, b_value, c_value=None):
    # 检查表达式是否有效
    if not is_expression_valid(expression):
        return False

    # 将变量值替换到表达式中
    expression = expression.replace("a", str(a_value))
    expression = expression.replace("b", str(b_value))
    if c_value is not None:
        expression = expression.replace("c", str(c_value))

    try:
        # 使用eval()评估表达式
        result = eval(expression)
        return result
    except Exception as e:
        # 如果评估过程中发生错误，返回False
        print(f"Error evaluating expression: {e}")
        return False


# 示例用法
expression = "a/b-2>=c"
a_value = 20
b_value = 4
result = evaluate_expression(expression, a_value, b_value, None)
print(result)  # 输出: True
